]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Connect to DnD signals using connectObject()
authorJonas Dreßler <verdre@v0yd.nl>
Sat, 5 Nov 2022 21:36:47 +0000 (22:36 +0100)
committerJonas Dreßler <verdre@v0yd.nl>
Wed, 30 Jul 2025 20:40:59 +0000 (22:40 +0200)
Currently DnD uses `disconnectAll()` in a `::destroy` signal handler for
the drag actor. This is a little weird, as usually the connecting object
is in charge of disconnecting as well.

Since we have some nice convenience API for this nowadays, use
`connectObject()` when connecting to DnD signals in the various draggable
actors that we have, which ensures the signal is disconnected as soon as
the draggable actors get destroyed.

This allows removing the call to `disconnectAll()` in DnD.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3796>

js/ui/appDisplay.js
js/ui/dnd.js
js/ui/windowPreview.js
js/ui/workspaceThumbnail.js

index c7959f3529f6f0042f76d54452b8975fc628f60e..0bc8f9ad5478846535567890aa352c4cb489121d 100644 (file)
@@ -1886,10 +1886,11 @@ class AppViewItem extends St.Button {
 
         if (isDraggable) {
             this._draggable = DND.makeDraggable(this, {timeoutThreshold: 200});
-
-            this._draggable.connect('drag-begin', this._onDragBegin.bind(this));
-            this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this));
-            this._draggable.connect('drag-end', this._onDragEnd.bind(this));
+            this._draggable.connectObject(
+                'drag-begin', this._onDragBegin.bind(this),
+                'drag-cancelled', this._onDragCancelled.bind(this),
+                'drag-end', this._onDragEnd.bind(this),
+                this);
         }
 
         this._otherIconIsHovering = false;
index 63a279b4bf5db44d957ddf5d0d243fa70a4bb0f7..c41e0f8ca574084deb6220002f0646762bd1d493 100644 (file)
@@ -119,7 +119,6 @@ class _Draggable extends Signals.EventEmitter {
 
             if (this._dragState === DragState.DRAGGING && this._dragCancellable)
                 this._cancelDrag(global.get_current_time());
-            this.disconnectAll();
         });
         this._onEventId = null;
         this._touchSequence = null;
index 95a2276ca6e60a46381e1fc457df084aff398566..3bc04187e4bd102d698650be497f142523b93122 100644 (file)
@@ -108,9 +108,11 @@ export const WindowPreview = GObject.registerClass({
             dragActorMaxSize: WINDOW_DND_SIZE,
             dragActorOpacity: DRAGGING_WINDOW_OPACITY,
         });
-        this._draggable.connect('drag-begin', this._onDragBegin.bind(this));
-        this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this));
-        this._draggable.connect('drag-end', this._onDragEnd.bind(this));
+        this._draggable.connectObject(
+            'drag-begin', this._onDragBegin.bind(this),
+            'drag-cancelled', this._onDragCancelled.bind(this),
+            'drag-end', this._onDragEnd.bind(this),
+            this);
         this.inDrag = false;
 
         let clickAction = new Clutter.ClickAction();
index a484dce12f3f4a8b75048fc2bb28c8a8656f2afb..d029563a7d449c66655b203f10ebdb70ba46515f 100644 (file)
@@ -86,9 +86,11 @@ export const WindowClone = GObject.registerClass({
             dragActorMaxSize: Workspace.WINDOW_DND_SIZE,
             dragActorOpacity: Workspace.DRAGGING_WINDOW_OPACITY,
         });
-        this._draggable.connect('drag-begin', this._onDragBegin.bind(this));
-        this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this));
-        this._draggable.connect('drag-end', this._onDragEnd.bind(this));
+        this._draggable.connectObject(
+            'drag-begin', this._onDragBegin.bind(this),
+            'drag-cancelled', this._onDragCancelled.bind(this),
+            'drag-end', this._onDragEnd.bind(this),
+            this);
         this.inDrag = false;
 
         const clickAction = new Clutter.ClickAction();